//导入request.js
import request from '@/utils/request'

// 定义访问注册接口
export const userRegisterService = (registerData) =>{
    const params =  new URLSearchParams()
    for(let key in registerData){
        params.append(key,registerData[key])
    }
     return request.post('/user/register',params)
}

// 登录接口 
export const userLoginService = (loginData) =>{
    const params =  new URLSearchParams()
    for(let key in loginData){
        params.append(key,loginData[key])
    }
     return request.post('/user/login',params)
}

// 获取用户信息
export const userInfoService = ()=>{
    return request.get('/user/userInfo');
}

//修改个人信息
export const userInfoUpdateService = (userInfo)=>{
    return request.put('/user/update',userInfo)
}

//修改头像
export const userAvatarUpdateService=(avatar)=>{
    let params = new URLSearchParams();
    params.append('avatar',avatar)
    return request.patch('/user/updateAvatar',params)
}

//修改密码
//修改密码
export const userPasswordUpdateService=(passwordData)=>{
    const params =new URLSearchParams()
    for(let key in passwordData){
        params.append(key,passwordData[key])
    }
    return request.patch('/user/updatePwd',passwordData)
}

